package com.yoso.core.exception;


import com.yoso.core.enums.AbstractEnum;

/**
 * 异常
 * @author shizejin
 * @date 2023/11/27 10:10
 */
public class BaseException extends RuntimeException {

    private int status = 500;

    public BaseException(int status, String message) {
        super(message);
        this.status = status;
    }

    public BaseException(AbstractEnum abstractEnum) {
        super(abstractEnum.getMessage());
        this.status = abstractEnum.getCode();
    }

    public BaseException(AbstractEnum abstractEnum, Object ... objects) {
        super(String.format(abstractEnum.getMessage(), objects));
        this.status = abstractEnum.getCode();
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    protected BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
